<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www..org"
      xmlns="http://www.w3.org/1999/html">
<head>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/css/public.css}" media="all"/>
</head>
<body class="loginBody">
<form class="layui-form" action="/login" method="post">
    <div class="layui-tab layui-tab-brief" lay-filter="tabs">
        <font th:text="账号登录"></font>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show" id="account_tab">
                <div class="layui-form-item input-item" style="margin-top: 20px;">
                    <label for="loginName">用户名</label>
                    <input type="text" placeholder="请输入用户名" autocomplete="off" name="loginName" id="loginName"
                           class="layui-input" lay-verify="required" autofocus="autofocus">
                </div>
                <div class="layui-form-item input-item">
                    <label for="password">密码</label>
                    <input type="password" placeholder="请输入密码" autocomplete="off" name="password" id="password"
                           class="layui-input" lay-verify="required" value="">
                </div>
                <div class="layui-form-item input-item" id="imgCode">
                    <label form="security_code">验证码</label>
                    <input type="text" class="layui-input" name="security_code" id="security_code"
                           style="width:50%;float: left;" placeholder="验证码" autocomplete="off">
                    <img title="看不清，换一个" alt="看不清，换一个" id="getGifCode"
                         style="width:45%;float: right;height: 36px; vertical-align: middle;cursor: pointer;"
                         onclick="javascript:this.src='/getGifCode?'+Math.random()">
                </div>

                <div class="layui-form-item">
                    <button class="layui-btn layui-block" lay-filter="login" lay-submit type="submit">登录</button>
                </div>
                <div class="layui-form-item" style="color: red">
                    <span id="c-tip" th:text="${errorInfo}"></span>
                </div>
            </div>

        </div>
    </div>
</form>
<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
<script type="text/javascript">
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
            layer = layui.layer
        $ = layui.jquery;

        //表单输入效果
        $(".loginBody .input-item").click(function (e) {
            e.stopPropagation();
            $(this).addClass("layui-input-focus").find(".layui-input").focus();
        });
        $(".loginBody .layui-form-item .layui-input").focus(function () {
            $(this).parent().addClass("layui-input-focus");
        });
        $(".loginBody .layui-form-item .layui-input").blur(function () {
            $(this).parent().removeClass("layui-input-focus");
            $(this).parent().parent().parent().removeClass("layui-input-focus");
            if ($(this).val() != '') {
                $(this).parent().addClass("layui-input-active");
            } else {
                $(this).parent().removeClass("layui-input-active");
            }
        });

        $("#getGifCode").attr("src", "/getGifCode?Math.random()");
    })
</script>
</body>
</html>
